<%-- 
    Document   : companies
    Created on : Dec 9, 2011, 2:59:44 AM
    Author     : Michael
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Companies</title>
    </head>
    <body>
        <input type="button" value="Home" onclick="window.location='/TheLoop/gohome.jsp'"/>&nbsp;
          <input type="button" value="Log Out" onclick="window.location='/TheLoop/logout.jsp'"/>
        <h1>All Companies</h1>
              <table width="800" border="1">
        <tr >
        <td >Company</td>
        <td >Item Name</td>
        <td >Item Type</td>
        <td >Unit Price</td>     
        <td >Date</td>
        </tr>
        <% 
            java.sql.Connection conn = null;
            try
            {
                conn = new DBClasses.GetConnection().getConnection();
                String query = "SELECT * FROM advertisement ORDER BY Company";

                java.sql.Statement stmt = conn.createStatement();
                java.sql.ResultSet rs = stmt.executeQuery(query);

                int i=0;
                while(rs.next())
                {

        %>
        <tr >
        <td ><%=rs.getString("Company")%></td>
        <td ><%=rs.getString("ItemName")%></td>
        <td ><%=rs.getString("ItemType")%></td>
        <td >$<%=rs.getDouble("UnitPrice")%></td>
        <td ><%=new java.text.SimpleDateFormat("M-d-yyyy").format(rs.getDate("Date"))%></td>    
        

        <%
                  }
           }
           catch(Exception e)
           {
               e.printStackTrace();
           }

           finally
           {
               try{
               conn.close(); }
               catch(Exception e) {
                   e.printStackTrace();
               }
           }
        %>
    
              </table>
    </body>
</html>
